package br.com.caelum.tarefas.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import br.com.caelum.tarefas.dao.TarefaDAO;
import br.com.caelum.tarefas.modelo.Tarefa;

public class RemoveTarefaAjaxAction {

	private Long id;
	private Tarefa tarefa;
	
	@Action(value="removeAjaxTarefa", results= {
			@Result(name="ok", type="httpheader", params= {"status", "200"})
		})
	public String execute() {
		tarefa = new TarefaDAO().buscaPorId(id);
		new TarefaDAO().remove(tarefa);
		return "ok";
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public Long getId() {
		return id;
	}
	
	public void setTarefa(Tarefa tarefa) {
		this.tarefa = tarefa;
	}
	
	public Tarefa getTarefa() {
		return tarefa;
	}
}
